<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta name="copyright" content=
    "Copyright (c) IBM Corporation and others 2000, 2011. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css" />
    <title>
      Editor Templates
    </title>
    <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js" type=
    "text/javascript">
</script>
  </head>

  <body>
    <h1>
      Editor Templates
    </h1>
    <p>
      Templates are a structured description of coding patterns that reoccur in source code. The
      Java editor supports the use of templates to fill in commonly used source patterns. Templates
      are inserted using content assist (<strong>Ctrl+Space</strong>).
    </p>
    <p>
      For example, a common coding pattern is to iterate over the elements of an array using a for
      loop that indexes into the array. By using a template for this pattern, you can avoid typing
      in the complete code for the loop. Invoking content assist after typing the word
      <code>for</code> will present you with a list of possible templates for a for loop. You can
      choose the appropriate template by name (<code>iterate over array</code>). Selecting this
      template will insert the code into the editor and position your cursor so that you can edit
      the details.
    </p>

    <p>
      Templates can contain <a href="../concepts/concept-template-variables.htm">template
      variables</a>. Variables mark the editable locations. They can be resolved to a concrete
      value when the template is evaluated in its context. They can also provide a list of
      alternative proposals valid at the given location.
    </p>
    <p>
      Many common templates are already defined. These can be viewed with the <a class=
      "command-link" href=
      'javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaTemplatePreferencePage)")'>
      <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt=
      "Goto the Java editor preferences page" /> <strong>Java &gt; Editor &gt;

      Templates</strong></a> preference page. You can also create your own templates or edit the
      existing ones.
    </p>

      <h3 class="related">Related References</h3>
      <a href="../reference/preferences/java/editor/ref-preferences-templates.htm">Templates
      preferences</a><br />
      <a href="../concepts/concept-template-variables.htm">Template variables</a><br />
      <a href=
      "../reference/preferences/java/editor/ref-preferences-edit-template-dialog.htm">Template
      editing</a><br />
      <a href="../reference/ref-menu-edit.htm">Edit menu</a><br />
      <a href="../reference/ref-java-editor-code-assist.htm">Java content assist</a><br />

  </body>
</html>
